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

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

SQL Date Format

I need to store GetDate() as '19000101213924'  As [nvarchar](50)

                                              YYYYMMDDHHMMSS
0
MBoy
Asked:
MBoy
  • 2
2 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
select CONVERT(varchar, getdate(), 112 ) + REPLACE(CONVERT(varchar, getdate(),108),':','')
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
not sure what exactl the logic behind that, to be frnak thats not a good idea, why dont you store it as datetime
0
 
SharathData EngineerCommented:
check this.

SELECT replace(replace(replace(CONVERT(varchar(50),GETDATE(),120),':',''),'-',''),' ','')
0
 
MBoyAuthor Commented:
why dont you store it as datetime - I agree but the communications check routines dictate

Thanks for your help!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

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