Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Format Date


Format Date

Author
Message
jafm
jafm
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 189
hi
I wanted to put a parameter by default DATE of yesterday?
How do I create the Format
mikehunsaker
mikehunsaker
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 180
Here is a list of the popular date calculations:

First Date of last month: =Format(DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)),"dd/MM/yyyy")
Last date of last month: =Format(DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)),"dd/MM/yyyy")
First date of current month: =Format(DateSerial(Year(Now()), Month(Now()), 1),"dd/MM/yyyy")
Last date of current month: =Format(DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Now()), Month(Now()), 1)))),"dd/MM/yyyy")
Yesterday's date : =Format(DateAdd("d", -1, now()),"dd/MM/yyyy")
tomorrow's date : =Format(DateAdd("d", 1, now()),"dd/MM/yyyy")
jafm
jafm
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 189
I do the following process

Parameter Properties --> Default Values --> Specify Values --> add --> fx --> =Format(DateAdd("d", -1, now()),"dd/MM/yyyy") --> ok

When I Preview gives this error

an error occurred during local report processing.
The property 'DefaultValue' of report parameter 'DateDe' doesn't have the expected type

What is the problem?
mikehunsaker
mikehunsaker
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 180
What happens if you wrap the expression in the CDate function? Like:

=CDate(Format(DateAdd("d", -1, now()),"dd/MM/yyyy"))
jafm
jafm
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 189
Already works. Thank you
mikehunsaker
mikehunsaker
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 180
Glad you got it working! Thanks for letting us know.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search