Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,How is the syntax written to get the date when a person turns into 18. For example a person born 19900101 will turn 18, 20080101. How can this be written with a select statement to recieve the result 20080101?
PeterNeo
Constraint Violating Yak Guru
357 Posts
Posted - 2008-04-01 : 04:49:37
start with this, may be some one may provide better solutionSELECT REPLACE(CONVERT(VARCHAR(10), DATEADD(YEAR, 18, CAST('19900101' AS DATETIME)), 120), '-', '')
Kurmanc
Yak Posting Veteran
92 Posts
Posted - 2008-04-01 : 04:53:10
Nice Job!
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-04-01 : 05:16:52
Use Style 112 instead and there is no need to replace.