[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7954
  • Last Modified:

SQL Cstr conversion

This is msAccess SQL that i am trying to parse in Query Analyzer -  i am getting an error on CStr.  Can someone tell me what I need to change to to use in SQL?

CDate("01/01/" & CStr(Year([entyear])-1)
0
LAppling7775
Asked:
LAppling7775
  • 2
2 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
select CONVERT (datetime ,'01/01/'+ CAST(Year(GETDATE()-1) as Varchar(4)) ,103) --dd/mm/yyyy
select CONVERT (datetime ,'01/01/'+ CAST(Year(GETDATE()-1) as Varchar(4)) ,101) --mm/dd/yyyy
0
 
Aneesh RetnakaranDatabase AdministratorCommented:

select CONVERT (datetime ,'01/01/'+ CAST(Year(EntYear-1) as Varchar(4)) ,103) --dd/mm/yyyy
select CONVERT (datetime ,'01/01/'+ CAST(Year(EntYear-1) as Varchar(4)) ,101) --mm/dd/yyyy
0
 
morisceCommented:
convert(datetime,"01/01/" + convert(varchar(4),datepart(year,[entyear])-1) ,101)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now