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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Quarterly Date - IIF or DateAdd?

Status
Not open for further replies.

smedvid

MIS
May 28, 1999
1,228
US
I have a need to compute the nearest Quarterly Date (forward) and the brain is not at 100% today I guess.

I thought this would work, but when I try to update - I get an error.

Code:
UPDATE tblData SET tblData.CDate_Qtr = IIf(Month([cdate])<=3,'3',IIf(Month([cdate])>3 And Month([cdate])<=6,'6',IIf(Month([cdate])>6 And Month([cdate])<=9,'9',IIf(Month([cdate])>9 And Month([cdate])<=12,'12',Month([cdate])))))+'/01/'+Year([cdate]);

' CDate_Qtr is a date/time field as is cdate.

Perhaps there is a DateAdd() that I could use?

Thanks in Advance,


Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 
Too much T-SQL and P/L SQL lately...

]))))) & '/01/' & Year([cdate]);

Should do the trick I think...


Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 



hi,
Code:
QtrDate: DateSerial(YEAR([YourDate]),INT((MONTH([YourDate])-1)/3)*3+1,1)


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top