A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert Text To Valid Date



 
 
Thread Tools Display Modes
  #1  
Old April 20th, 2010, 11:17 AM posted to microsoft.public.access
zyus
external usenet poster
 
Posts: 210
Default Convert Text To Valid Date

I have text field of [Yr] and [mth] and sample records as follow

[Yr] [mth]
2010 01
2010 02

How to convert the two fields as a valid year & month date

Thanks
  #2  
Old April 20th, 2010, 12:15 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Convert Text To Valid Date

hi,

On 20.04.2010 12:17, zyus wrote:
I have text field of [Yr] and [mth] and sample records as follow

[Yr] [mth]
2010 01
2010 02

How to convert the two fields as a valid year& month date


SELECT DateSerial([Yr], [mth], 1) As SampleDate, *
FROM yourTable


mfG
-- stefan --
  #3  
Old April 20th, 2010, 04:41 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert Text To Valid Date

On Tue, 20 Apr 2010 03:17:01 -0700, zyus
wrote:

I have text field of [Yr] and [mth] and sample records as follow

[Yr] [mth]
2010 01
2010 02

How to convert the two fields as a valid year & month date

Thanks


Note that a Date/Time field *always* contains a complete date, including a
day: there's no such thing as a "year and month date". The Date/Time value is
actually stored as a number, a count of days and fractions of a day (times)
since midnight, December 30, 1899. As such it corresponds to a precise instant
of time. January 2010 was not a precise instant of time, it was a whole bunch
of them (some pleasant instants, some irritating....).

Stefan's DateSerial expression will give you a date, arbitrarily picking
midnight at the beginning of the first day of the month; but if you only
display the year and month of the date, you should be OK.
--

John W. Vinson [MVP]
  #4  
Old April 21st, 2010, 01:54 AM posted to microsoft.public.access
zyus
external usenet poster
 
Posts: 210
Default Convert Text To Valid Date

Hi John,

Can i use Stefan's date serial expression with below expression that you
have suggested before on special tagging. I want to include a valid date
(month & Year)

TblTag: IIf(Val([month])-Val(DMax("[MONTH]","Qunionall"))=0,"Current
Month","Previous Month")



"John W. Vinson" wrote:

On Tue, 20 Apr 2010 03:17:01 -0700, zyus
wrote:

I have text field of [Yr] and [mth] and sample records as follow

[Yr] [mth]
2010 01
2010 02

How to convert the two fields as a valid year & month date

Thanks


Note that a Date/Time field *always* contains a complete date, including a
day: there's no such thing as a "year and month date". The Date/Time value is
actually stored as a number, a count of days and fractions of a day (times)
since midnight, December 30, 1899. As such it corresponds to a precise instant
of time. January 2010 was not a precise instant of time, it was a whole bunch
of them (some pleasant instants, some irritating....).

Stefan's DateSerial expression will give you a date, arbitrarily picking
midnight at the beginning of the first day of the month; but if you only
display the year and month of the date, you should be OK.
--

John W. Vinson [MVP]
.

  #5  
Old April 21st, 2010, 05:04 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert Text To Valid Date

On Tue, 20 Apr 2010 17:54:02 -0700, zyus
wrote:

Hi John,

Can i use Stefan's date serial expression with below expression that you
have suggested before on special tagging. I want to include a valid date
(month & Year)

TblTag: IIf(Val([month])-Val(DMax("[MONTH]","Qunionall"))=0,"Current
Month","Previous Month")


Stefan's expression will return a valid date/time value. You can use it
wherever you would use a date/time value. If [month] in the above is in fact a
date/time, then yes, you can replace [month] with the expression.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.