What is the correct expression used to format dates from "yyyyMMdd" to "M / d / yyyy" in SQL Server Reporting Services?

I get dates in my dataset in the form of "yyyyMMdd" (that is, 20080228 means February 28, 2008)

I need to convert them to "M / d / yyyy"

Examples:

20080228 = 2/28/2008
20080101 = 1/1/2008
20081001 = 10/1/2008
20081212 = 12/12/2008

Which correct expression should handle this?

EDIT

The expression I used (ORDDTE is in the format "yyyyMMdd" and I have a switch for the Spanish or English date format):

=CDate(Mid(First(Fields!ORDDTE.Value, "ReturnTagHeader").ToString(), 5, 2) + "/" + Right(First(Fields!ORDDTE.Value, "ReturnTagHeader").ToString(), 2) + "/" + Left(First(Fields!ORDDTE.Value, "ReturnTagHeader").ToString(), 4)).ToString(IIf(Parameters!Language.Value = "ES", "d/M/yyyy", "M/d/yyyy"))
+3
source share
8 answers

. . , // 2- 2- , ... :

=MID(Fields!ORDDTE.Value.ToString(), 5, 2) 
  + "/" + RIGHT(Fields!ORDDTE.Value.ToString(), 2)
  + "/" + LEFT(Fields!ORDDTE.Value.ToString(), 4)

- ... found ...

=System.DateTime.ParseExact(Fields!ORDDTE.Value,"dd/MM/yyyy",System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("yyyyMMdd")
+3

, FormatDateTime()

: formatdatetime(FieldWhatever, 0)

0 , .

+2

:

Format(FieldWhatever,"MM/dd/yyyy")
+2

datetime sql- .

Select CAST(DateField AS datetime) As Date FROM DateTable

:

=Cdate(Fields!Date.Value).ToShortDateString
+2

, datevalue , MID().

DATEVALUE = 20080901 < - yyyyMMdd

= (cSTR (DATEVALUE), 5, 2) & "/" & (cSTR (DATEVALUE), 7, 2) & "/" & (cSTR (DATEVALUE), 1, 4)

+1

Report Services :

select 
    CONVERT(VARCHAR(10), [dateField], 101) as 'date' 
from someTable

, , , .

0

...

" " " " ? .

"d" . CDate.

0
SUBSTRING((DT_WSTR,30)DATEADD("D",-1,GETDATE()),1,4) + 
SUBSTRING((DT_WSTR,30)DATEADD("D",-1,GETDATE()),6,2) +
SUBSTRING((DT_WSTR,30)DATEADD("D",-1,GETDATE()),9,2)
0

Source: https://habr.com/ru/post/1704223/


All Articles