DateSerial Question

B

Bonnie A

Hi everyone! Using A02 on XP. Got the answer I needed earlier from Van and
Marsh but now I've been asked to default to 12/31 of the PRIOR year. I have
put a minus one in every spot but it's not working.

DateSerial(Year(Date()),12,31) gives me 12/31/2006.

DateSerial(Year(Date()-1),12,31) I need 12/31/2005.

I've read the VB help and the only examples are calculating from a specific
year rather than using Date().

What am I doing wrong? I know it's gotta be really simple and I'm missing it.

Thanks in advance for any help or advice.
 
A

Andrew Tapp

Almost right, try using DateSerial(Year(Date())-1,12,31), the -1 was in the
wrong place.

Hope this helps.
 
F

fredg

Hi everyone! Using A02 on XP. Got the answer I needed earlier from Van and
Marsh but now I've been asked to default to 12/31 of the PRIOR year. I have
put a minus one in every spot but it's not working.

DateSerial(Year(Date()),12,31) gives me 12/31/2006.

DateSerial(Year(Date()-1),12,31) I need 12/31/2005.

I've read the VB help and the only examples are calculating from a specific
year rather than using Date().

What am I doing wrong? I know it's gotta be really simple and I'm missing it.

Thanks in advance for any help or advice.


Using DateSerial, the Zeroeth day of any month is the last day of the
previous month, so January 0, 2006 returns December 31, 2005.

DateSerial(Year(Date()),1,0)
 
B

Bonnie A

Thank you very much Mr. Tapp. I really appreciate your help. I knew it was
simple.
 
Top