473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL insert into with Hijri date

18
I have a problem with Insert into SQL statement. When I use the below SQL to insert a Hijri date , the date will be stored in the table as Gregorian date.

How can I specify the date that I am inserting into the table is Hijri date not Gregorian date.

Expand|Select|Wrap|Line Numbers
  1. dbsCurrent.Execute "INSERT INTO Rent ([RentDueDate]) VALUES" & "(#" & [Text_RentDueDate] & "#)"
Sep 14 '07 #1
9 8789
Scott Price
1,384 Expert 1GB
Try:

Expand|Select|Wrap|Line Numbers
  1. Application.SetOption "Use Hijri Calendar"
Regards,
Scott
Sep 14 '07 #2
Busbait
18
Thanks Scott for your replay, but still its not working

I will explain the problem with more details and examples as follows:

When I use the below code to insert the Hijri date “2 / 9 / 1428” which is equivalent to “14 / 9 / 2007” , MS Access will recognize and insert the date “2 / 9 / 1428” as Gregorian date and since I have already selected the option to use “Hijri Calendar”, MS Access will convert “2 / 9 / 1428” as Gregorian to “14 / 04 /831” as Hijri date , which is not correct as the original Hijri date is “2 / 9 / 1428”

The final result that will be stored in the table is “14 / 04 /831” as Hijri date and as you can see it is totally different from the date that I have used in the code “2 / 9 / 1428”.

Your help is highly appreciated
----------------------------------------------------------------------------------------
Dim dbsCurrent As Database
Set dbsCurrent = CurrentDb
Application.SetOption "Use Hijri Calendar", True
Calendar = vbCalHijri

dbsCurrent.Execute "Insert Into Rent ([RentDueDate]) VALUES (#" 2 / 9 / 1428 "#)"
dbsCurrent.Close
Sep 14 '07 #3
Scott Price
1,384 Expert 1GB
Have you changed the regional settings in the Windows control panel to make sure they are using Hijri date also?

Regards,
Scott
Sep 14 '07 #4
Busbait
18
Yes, I have already changed the regional settings to use Hijri date, but no luck
Sep 14 '07 #5
Scott Price
1,384 Expert 1GB
Yes, I have already changed the regional settings to use Hijri date, but no luck

Well, after a little digging around I found this in the Access/VBA help file:
Use International Date Formats in SQL Statements
See AlsoSpecificsYou must use English (United States) date formats in SQL statements in Visual Basic. However, you can use international date formats in the query design grid.
Try setting your query up in the query design grid, and then opening it from vb code.

Regards,
Scott
Sep 14 '07 #6
Busbait
18
Thanks Scott for your efforts

I will check the query design grid and see the results
Sep 14 '07 #7
MAKADA
1
I know this a pretty old thread, but here is the solution in case it benefits anyone:

Add
calendar=vbcalgreg
before
dbsCurrent.Execute "INSERT INTO Rent ([RentDueDate]) VALUES" & "(#" & [Text_RentDueDate] & "#)"
and then at the end
add
calendar=vbcalhijri

this way date is converted to gregorian and stored, so when it is retrieved it is then converted back into hijri

( It works in ms access 2007)
May 25 '09 #8
SQL/MS Access dont support hijri calender you just add 1000 years into hijri years and save it to sql and while retrieving just minus 1000 years everything will be ok... ;) like if your date is 01/05/1429 this will be 01/05/2429 and will be save easily.. and while retrieve minus 1000years willl be on its original stat..
Oct 25 '11 #9
NeoPa
32,556 Expert Mod 16PB
Access supports the Hijri calendar. This has no effect on how dates are stored though. Today doesn't stop being today because I think of it in Hijri or Gregorian. SQL doesn't support Hijri literal dates (which I think is what this is actually about). Using literal dates in SQL is the same for any type of calendar and is done using m/d/yyyy format (as has been mentioned already in this thread). See Literal DateTimes and Their Delimiters (#) for more on this.
Oct 25 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Thomas Jerkins | last post by:
Assume I got a database resp. table defintion with a DATE field. How do I find out in which format the field should be filled in an INSERT SQL statement? Sometimes when I enter e.g. INSERT...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
1
by: glenn | last post by:
Hi folks, I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL...
1
by: shyam vashista | last post by:
i have problem in validation check for system date with server date problem::: If i change my system date as september 30, 2006 and use validation for filling form as current date as oct30,...
1
by: valve2nd | last post by:
This is probably a bonehead question, but I can't make it work. I want to prompt the user for a single date and select all records with a date falling within the week prior. Obviously this works:...
0
by: gpspocket | last post by:
help me -CURSOR backward insert from End Date > to Start Date how to insert dates from end to start like this SELECT 111111,1,CONVERT(DATETIME, '17/03/2008', 103), CONVERT(DATETIME,...
4
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello to all. Please help me. I'm inserting a date into sqlserver 2005 using C#3. my problem is while insert is successfull my date and time. It's possible to insert only a date? -- To be...
10
by: viki1967 | last post by:
Help with check date and hours Hi all. I have this form: <html> <head>
0
by: cik nur | last post by:
hi... i have one problem in my programming using vb.net... i want to insert data into database, using multiple condiction (if else statement)... before it save, it check wheather the matrix no...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.