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

Convert Function Issue

Status
Not open for further replies.

Sydney1

Technical User
Jul 14, 2004
156
US
Good morning,

I'm attempting to create a 90 day bucket in SQL where it begins on the second day of the month and ends on the first day of the next month. So far I have the following code, which I transferred from Access and then adjusted for SQL Server,

WHERE ((((vwMainWithInvestor.NextPaymentDueDate) Between DateAdd(month,-3,convert(varchar,GetDate(),'mm/''02''/yyyy')) And DateAdd(day,-1,DateAdd(Month,-2,convert(varchar,getDate(),'mm/''01''/yyyy'))))))

I'm receiving the following error "Argument data type varchar is invalid for argument 3 of convert function" at the MM/01/yyyy part. When I change the convert from varchar to datetime, I still get the same error. The NextPaymentDueDate is a datetime field.

Thanks in advance for your assistance.

Sydney
 
CONVERT requires three values.
1. the datatype
2. the expression to convert
3. the type of conversion
example: CONVERT(VARCHAR, GETDATE(), 101)

Refer to the BOL for more information on the syntax. Use the Index tab, enter CONVERT and choose the option for Transact SQL.

-SQLBill

BOL=Books OnLine=Microsoft SQL Server's HELP
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine
or online at:


Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top