Date Criteria in Microsoft Access - ms-access

I am trying to use MS-Access to fiter my dates. Example--> from yesterday till today
i am using the formula in criteria as below:
=Val(Year(Date()-1))*10000+Val(Month(Date()-1))*100+Val(Day(Date()-1))--this is for yesterdays date
its not working as its says Please chk the code and recompile. SOme how same formulaworks in another version(older version) of MS access.
Can you please help with this? is there any setting/Plugin we need to have?
Thanks in advance.

It is far easier to use DateAdd to get dates relative to another date:
=DateAdd("d",-1,Date())
Will give you yesterday's date:
Regards,

Related

How to display uppercase week day in SSRS expression

I am using SSRS to produce a report where I like to format the date from 20/01/2017 to FRIDAY (uppercase) instead.
=UCase(FormatDateTime(Fields!Start_Time.Value,DateFormat.ShortDate))
What I have tried:
=UCase(FormatDateTime(Fields!Start_Time.Value,"dddd"))
However, If I leave the custom field as =dddd then it displays Friday.
Question is how to convert to uppercase?!
Your help is much appreciated.
UPDATE
The correct syntax would be:
=UCase(Format(Fields!Start_Time.Value,"dddd"))
Thanks to MiguelH & Muhammad Saqlain
The correct syntax would be:
=UCase(Format(Fields!Start_Time.Value,"dddd"))
Credit goes to MinguelH

Can't get the Today() function to work properly in MS Access 2016 Custom Web App

I'm trying to setup a query that will show me all of the records in a particular table where the listed expiry date is either in the past or upcoming in the next 6 months (approximately).
At the moment, I have the "Expiry" field added to my query and the 'Criteria' as .
When I try to save the query, I get the following message:
Access can't evaluate an expression or convert data because data types aren't compatible with each other.
TECHNICAL DETAILS
Correlation ID: ae68949d-3041-3000-0984-71635f8fd670
Date and Time: 7/28/2016 6:54:34 PM
I've tried searching the web for a solution, but most websites refer to the Date() function that doesn't seem to be available in the Access 2016 Custom Web App. When I take out the "+180", it works fine but obviously doesn't give me what I need.
Any help would be appreciated.
=============================
UPDATE:
Some users have asked for my SQL and Table Design details. I don't seem to have any way of accessing the SQL View (the option doesn't appear), but here's a copy of my table view:
Access Query Table Design
In the table, 'Active' is a Yes/No field and 'Expiry' is Date/Time.
Try
< DateAdd(Day, 180, Today())
as criteria.
According to https://msdn.microsoft.com/en-us/library/office/jj249452.aspx this should work in a custom web app.
Error says that you have two different date types and they can't be compared. so, as the Today() returns only the Date with 12:00 pm, I can guess that your other "Expiry" Field is a datetime type. So, you can do either: use Format function to convert datetime to date like this
Format([2/22/2012 12:00 PM],"dd/mm/yyyy")
or use Now() function which returns datetime,
or Share your Code :)

=WeekdayName(weekday(Today())) gives me tomorrow

I have noticed with one of my reports (SSRS), when I add weekdayname, that tomorrow's value appears.
I tested this by adding a textbox with =WeekdayName(weekday(Today())) in it. I have just run this (on a Monday) and it is saying Tuesday. So clearly it's one day out.
Does anyone know how I can go about rectifying this? I can get round it in reports by adding an expression but I suspect there's some deeper problem that I would like to rectify.
Any advice would be much appreciated.
Try specifying the first day of the week in the Weekday function to be determined by the system settings.
=WeekdayName(Weekday(Today(),FirstDayOfWeek.System))

MS Access stores the date as 30/12/1899 and not the actual date

whenever I am pushing the data from VBA code to an Access table the date field is stored as 30/12/1899 and not the actual date ? I tried formatting the date to mm/dd/yyyy before writing to the table but no success. Thanks in advance for the help
In VBA you need to use US date format AND surround the date with # signs so today would be
#02/20/2015#

Microsoft Access Datediff issue

I feel like this shouldn't be hard at this point.. but for some reason I cannot figure it out. Using Microsoft Access to calculate someone's age at a certain date with this.
=DateDiff("yyyy",[Dob],(2/1/2014))+Int(Format((2/1/2014),"mmdd")<Format([Dob],"mmdd"))
Where Dob = 5/14/2003 . It is returning -104.
Try the following:
=DateDiff("yyyy",[Dob],#2/1/2014#)+Int(Format(#2/1/2014#,"mmdd")<Format([Dob],"mmdd"))
DATEDIFF("d",[Dob],(2/1/2014))/365
Get the days and divide by 365 instead...