How to add day(+1) to date which is in (mm/dd/yyyy) using sparkSQL - mysql

I have a dataset with a column which has data in the form dd/mm/yyyy Now using the sparkSQL i want to add 1 day to the current date. I have tried with Date_add function but got an exception that the function doesnt exist

You are probably looking for this:
Check the documentation
There is also a possible duplicate :
How to get today -"1 day" date in sparksql?
If this does not get you anywhere please post the exact exception

Related

How to retrieve date from database

I have a column in my database that is of type DATE.
I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).
r.setRkd(Date.valueOf(LocalDate.now()));
The entry is correct because the exact date appears in the table.
rkd
------------
2022-03-02
The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.
"rkd": 1646175600000
Do you know how I can print the correct date in my JSON?
Thank you in advance.
That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD
If you need to display it in date format there should be a method to do it depending on the specific language that you're using.

Adding Parameter to DateDiff Function

Not sure I am going at this the best way, I would like to make the last parameter of the DateDiff formula something the user enters. I get the parameter popup, but when I enter the desired date in the popup I get an error (screen shot of error is below):
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),Format([Enter the date you wish to pull from],"mm/dd/yyyy")+1)
I have tried putting a # in the parameter popup and I also tried not putting the parameter in a Format, like this but it results in the same error:
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),[Enter the date you wish to pull from]+1)
Error Message
First, specify the Parameter as DateTime:
[Enter the date you wish to pull from]
Next, use it as a date:
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),[Enter the date you wish to pull from])+1

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 :)

Access parameter query with optional second parmeter

I have an ACCESS database that has a table with date as one of the fields. I can create a form that allows the user to enter a start date and end date and then use those in a query to filter the date for only records between those dates. But I would like to make the end date optional so if the user would only enter the start date the query would return on records greater than that date. I am trying to do this with one query and without getting into VBA but not sure if this can be done.
I tried something like this but it did not work...I got error message saying the syntax was not correct or I got no results at all.
In the date field criteria I tried
IIF(isNull([Forms]![frmdateselect]![enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))
Any help would be great
Have you tried replacing the IsNUll with the Nz function?
IIF(Nz([Forms]![frmdateselect]![enddate]),0),
([Forms]![frmdateselect]! [enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))

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")