Date/Time formatting in access textbox - ms-access

I have an issue, and believe its simple to resolve but cant work out how.
My table, which has showing both date & time can not be amended because that is how I receive my data.
Ive changed the format in the table design to short date and it shows fine, it hides the time.
I also changed the textbox that displays the date to short date but its still showing both the date and time, why?
Primarily, I have another textbox that I want to calculate the table date + 30, my expression used is:
=[text5]+30
The textbox is displayed blank.
Any help?

It sounds like your date field is linked as text. So convert to Date:
=DateValue([OpenedDate])
and for the +30 date:
=DateAdd("d",30,DateValue([OpenedDate]))
However, there is no way that:
? DateValue(Now() + 30)
can show today's date. It will show 30 days ahead of today.

Related

Auto populate dates of the week Paginated reports

Good day
I am very very new two paginated reports so forgive me if this is a silly question
I have a report that displays values for Mondays to Fridays based on the date selected from a date picker.
So basically
You select a date (Example 24 Nov) and the following table is displayed based on values pulled from SQL.
Now my question is how do I display the dates of the weekdays too?
So if the date selected is Thursday 24 Nov, in the column headers under the week day names it should give the corresponding date i.e Monday-21/11/2022, Tuesday - 22/11/2022, etc.
Below is a little snippet of the data
So the date picker is based on the ReportingDate column. The rows of the matrix consist of Region and Country and the values are the sum of Monday-Friday.
Any guidance would be greatly appreciated.
Edit: The day names are not obtained via an expression in SSRS. They carry over from the column headers in the data set.
Assuming you have some expression to get the actual day name already, you can leave that bit as it is.
Now, double click the column header "cell"/textbox to get a cursor in there, then click at the end of the existing fields/expression.
Now just put a space in and then right-click and choose "Create Placeholder". The placeholder dialog will appear.
This placeholder acts almost like a separate textbox to you can put whatever you want in there, click the '[fc]' button next to the Value property and then set this to whatever you want, e.g. =Fields!ReportingDate.Value.
Now go to the "number" tab on the same dialog box and set the format to the required date format.
If you want to edit this later, just double click the cell again but this time right-click the placeholder and choose properties.
The other way of doing this would be to add another row to your header and set that to be the date instead but then you have to mess around removing borders etc., sometimes this can be easier if layout is an issue but you have a couple of options at least now.
I managed to figure it out with the help of the following post.
These are the steps I followed
Get the date of the first day of the current week (Sunday's date) using the formula explained in the link
DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))
Use DateAdd to add the corresponding number of days to get to a required weekday. That is for Monday add 1, Tuesday add 2,...
DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value)))
Format datetime to date and add new line to insert date below day name
="Monday" + Environment.NewLine + FormatDateTime(DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))), DateFormat.ShortDate)

SSRS date time parameter

I'm trying to load default values in my report, like below screenshot. From to field is 'Yesterday' and to field is 'Today' or 'Now'
I can't seem to make this to work. I want to load yesterday's date and convert time format to dd-MMM-yyyy
=CDate(DateAdd(DateInterval.Day, -1, Now()).ToString("dd-MMM-yyyy")
This one works fine,
=CDate(Now).ToString("dd-MMM-yyyy")
Any idea?
It's simpler than I thought, I got it to work.
=CDate(Now.AddDays(-1)).ToString("dd-MMM-yyyy")

Now() function is only showing date not time

So I'm making a report in Access, I call
=Now() and it only shows the date and not the time. How do I fix this?
I'm using access 2013.
Assuming your report contains a text box where you want to display the current date and time, leave its Control Source property as simply =Now() and use the text box's Format property to display the date and time as you wish.
If none of the available selections offers the exact format you want, you can enter a custom format as in this example:
And this is the same report in Report View:
I have also noticed reports do this. I just change the field to be something like
=Date() & " at " & Time()
It depends on system date setting. Use Format(now(),"general date") in place of now(). Alternatively, you can use format(now(),"dd/mm/yyyy hh:mm ampm") to show date with time in AM/PM form. You can omit "ampm" to show time in 24 hour format.

dd/mm/yyyy date format in SSRS

i'm trying to specify dd/mm/yyyy dateformat for date/time parameter in SSRS 2008 R2.
My computers datetime format is mm-dd-yyyy.
My requirement is, i want to show date format at dd/mm/yyyy irrespective of the system/server date format.
I've already tried CDate(Format(Today,"dd/mm/yyyy")) which didn't work. one very strange thing i observed is, it shows dd/mm/yyyy format only for dates on or before 12-MM-yyyy, and 13 onwards it gives error: Conversion from string '25-04-2014' to type Date is not valid. (Possibly it is trying to map 25(daypart) with MM-dd-yyyy (month part)) which is out of range of total months i.e. 12)
my research on internet says it is a bug in BIDS 2008.
What do i do to display date as dd/mm/yyyy ??
I don't have enough reputation to comment, but I did notice that you failed to put "()" after "Today". If I'm not mistaken you must put Today() for that function to work. Also, you might want to try putting CDate Around the Today() function. You shouldn't need it, but it's worth a shot. Also, for some odd reason, in my experience, you must capitalize MM for format to work correctly.
Like #Aditaya said, it should be =format(Today(),"dd/MM/yyyy")
The expression I usually use is:
=FormatDateTime(Fields!Date.Value, DateFormat.ShortDate)
However, this may be region specific.
Rather than writing an expression to do the formatting, you can also use the Textbox Format Property. But first you need to make sure that the data is in a date format. So use the CDate function on your column like this:
=CDate(Fields!Date.Value)
Then in the textbox properties go to the Number tab. Select Date for the category. Then you can select whichever format you want or use a Custom format. This will change how the column displays when you run the report.

Showing Date in a specific format

I need to make the date format that I entered into the database look exactly the same as when i view it. Eg. Currently my format is 2013-12-21, but when i view it, it shows 12/21/2013. It's quite confusing because when I edit the date in my form, it's in the 12/21/2013 format and the database wont accept it when i change the date to something like 12/23/2013. Please help. Thanks
(btw, it just auto formatted my date. I didn't even use the <%formatdatetime%> function.)
EDIT: Sorry for the lack of information guys. This is what's happening.
1. I created a form to add date amongst othes to mysql. Eg. Purchase date, item, etc (sql wants it in yyyy-mm-dd format and that's how i enter it.
2. created a view list to select which rows i want to update. (Used
<%=Formatdatetime(f_purchasedate,2)%>
to show date only without time as it was 12/21/2013 12:00:00 AM)
3. created an update form.
Now the problem is it shows the date as 12/21/2013 instead of 2013-12-21. So when i submit the form after altering other fields, it says date error. I have to manually type the format 2013-12-21 for all my dates before i can submit the form.
i'm guessing it has something to do with this line of mine.
purchasedate.Text = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)
tried this but it doesnt help either...
formatDateTime('purchasedate').Text.ToString("yyyy-MM-dd") = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)
You can use DATE_FORMAT(date,format)
Select DATE_FORMAT('Your Date Value'),%Y-%m-%d) as Date from table_name
Or
You can pass the value to a variable like below
purchasedate.Text = CType(ODBCdataset.Tables("tbl_vehiclemanagement").Rows(0).Item(2).ToString, DateTime).ToString("yyyy/mm/dd")
Dim date As String = DateTime.Now.ToString("yyyy/mm/dd")