Date Serial for 12 months ago?

gojets1721

Registered User.
Local time
Today, 09:19
Joined
Jun 11, 2019
Messages
430
I was hoping to use a dateserial function to produce a date that is 12 months prior to today's date.

So if today is 11/10/2022, then the date serial function would show 11/11/2021. Basically exactly 365 days prior.

Any suggestions?
 
Basically exactly 365 days prior.

Basically exactly? That's some fine wordsmithing.

You would literally figuratively use DateAdd, not DateSerial:


Be careful when you cross over leap days--what basically exactly do you want for 12 months/365 days prior to 3/3/2024? Pretty sure -12 months produces a different result than -365 days.
 
Datesserial(year(date),month(date),day(date)-1)
 
FYI. The date serial is really smart. If the day is the first of the month and you subtract 1 you are providing 0 as the day. It will convert to last day of previous month. Same if you provided a day like 32.
 
FYI. The date serial is really smart. If the day is the first of the month and you subtract 1 you are providing 0 as the day. It will convert to last day of previous month. Same if you provided a day like 32.
Perfect. Thank you!!
 
Well, I would possibly subtract 1 from the year rather than the day section of the function?

Try it and see what happens. It won't bite you.
 
Sorry typed on a phone. Subtract one from year, year(date) -1 and add a day not subtract.
 
Point is you want it to be a day before in the previous year. Not always 365.
Unless you do want 365 regardless of leap year. Need to be specific which way.
 

Users who are viewing this thread

Back
Top Bottom