Last date of the given month and year
Team,
I am finding it hard to calculate the last date for the given month and year. I searched Date library and couldn't figured it out from there. For instance if the input is year - 2015 and month - 12 the output should be 31.
Is the only way to write UDF with hardcoded last date monthg values considering the leap year or any other ways within date lib ?
I am finding it hard to calculate the last date for the given month and year. I searched Date library and couldn't figured it out from there. For instance if the input is year - 2015 and month - 12 the output should be 31.
Is the only way to write UDF with hardcoded last date monthg values considering the leap year or any other ways within date lib ?
- ravishankar
- Posts: 17
- Joined: Wed Mar 18, 2015 5:24 am
ravishankar,
You can get the Days_t value for the first day of the next month and subtract 1, then translate that back to a Date value. Something like this:
HTH,
Richard
You can get the Days_t value for the first day of the next month and subtract 1, then translate that back to a Date value. Something like this:
- Code: Select all
IMPORT STD;
D := STD.Date.FromGregorianYMD(2015,12 + 1,1) - 1;
X := STD.Date.ToGregorianYMD(D);
X.Day; //returns 31
HTH,
Richard
- rtaylor
- Community Advisory Board Member
- Posts: 1619
- Joined: Wed Oct 26, 2011 7:40 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest