SELECT TOP 5 CreationDate ,CAST(CreationDate as DateTime)...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Open Source Meta

Q&A about the site for people organizing, marketing or licensing open source development projects

SELECT TOP 5 CreationDate
   ,CAST(CreationDate as DateTime) as CreatDatedatetime
   ,DATEADD(M, -3, GETDATE()) as CurrenDate3MonthAgo
   ,creationDate+2*365/12  as CreationDatePlus2Months
   ,datediff(MONTH,creationDate, getDate()) as PostAgeInMonths
   ,CAST(CreationDate as Date) as CreationDateAsDate
   ,CAST(CreationDate as Time) as CreationDateTime
   ,CAST(CreationDate as Char) as CreationDateAsVarchar
   ,CONVERT(VarChar, CreationDate, 104) as CreationDateLVFormat
   ,CONVERT(VarChar, GetDate(), 104) as todayDateLVFormat
   ,MONTH(CreationDate) as CreateDateMonth
   ,Year(CreationDate) as CreateDateYear
   ,CASE WHEN Year(CreationDate)>=2021 THEN 'Jauns' ELSE 'Vecs' END as Vecums
   ,CASE WHEN (Year(CreationDate)*12+MONTH(CreationDate)+2)>=(Year(GetDate())*12+MONTH(GetDate()))
      THEN 'New'
      ELSE 'Old'
   END as OldOrNewPost
FROM Posts
WHERE CreationDate>=CAST('2021-06-01' AS DATE)
AND CreationDate<=CAST('2021-06-05' AS DATE)

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results