Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a date

Status
Not open for further replies.

dstepans

Programmer
Joined
Jun 3, 2003
Messages
39
Location
US
Hello,

I need to get a day, month and year out of the date field. For example todays is 11/21/03 so i will need to get: month 11, day 21, year 03

Any suggestions?

Thanks,
Denis
 
Use the DatePart function:

DatePart (intervalType, inputDateTime)

yyyy - Extracts the year
m - Month (the result is from 1 to 12)
d - Day part of the date (1 to 31)

-dave
 
Assuming that this is a string not a date datatype you can use this

//@ParseDate

WhilePrintingRecords;
numberVar tYear;
NumberVar tDay;
NumberVar tMonth;

// assuming this format "11/21/03"

tYear := toNumber({table.dateString}[7] to [8]);
tDay := toNumber({table.dateString}[4] to [5]);
tMonth := toNumber({table.dateString}[1] to [2]);

If the field is a date then it is trivial

Year({table.date})
Day({table.date})
Month({table.date})

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Thanks guys, that worked.

Denis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top