Convert Text To Valid Date

Z

zyus

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
 
S

Stefan Hoffmann

hi,

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 <--
 
J

John W. Vinson

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.
 
Z

zyus

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 said:
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.
 
J

John W. Vinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top