Login | |
|
 |
Date problem for 9/1/2007 - 9/2/2007 3:22:34 AM
|
|
 |
|
| |
ChadR
Posts: 24
Score: 0
Joined: 8/20/2007
Status: offline
|
Hi all, I have a problem I am hoping someone can help me resolve. My script checks a number of business created logs which contain date strings in this format: MMDDYYYY Yesterday; September 1st, 2007, my script failed to check a number of logs because it returned the date as 09312007. Here is the code which obtains this date format for these logs: dateYesterdayMMDDYYYY=Right("0" & Month(Date),2) & Right("0" & Day(Date - 1),2) & Right("0" & Year(Date),4) I know why it returned 09312007, but I need to resolve this for the future so it doesn't happen again next month: Notice that the code returns the current month (09,) then the current day minus one (31, because yesterday was the 1st.) How can set this variable so that it is aware if it is the first day of the month? And not only subtract one from the day but also the month? I use this variable every day because some of the logs we must check contain the previous days date, but I also want it to work when the 1st of the next month comes. Anyone have any ideas at all? This is bugging me so bad right now! Thanks, Chad Edit: BTW, I know I could use an if statement to check if today is the 1st, but I am hoping I can resolve this in a simpler way. I like to know the most efficient ways of doing things :)
< Message edited by ChadR -- 9/2/2007 3:25:39 AM >
|
|
| |
|
|
|
|
|