Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Gregorian Date to Hijri Date

Posted on 2004-03-29
11
647 Views
Last Modified: 2007-12-19
Hi,

one of my table having a date/Time field (Gerigorian), How can i convert that in to Hijri (Arabic) Date in Form and Report Without changing the Tables' date format. My DataBase is in Access XP.

Thanks in advance
0
Comment
Question by:deemas
  • 5
  • 5
11 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10702370
if your posting twice, r u gonna award twice the points?
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10702427
*********** THIS IS A DUPLICATE QUESTION ***********

Experts please don't add a comment..................

Questionner,

Please post a zero points question at:
http://www.experts-exchange.com/Community_Support/

With the link (URL-address) of this Q asking for a refund and delete !

Thanks !

Nic;o)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10712210
note, this question is not being deleted

but the other question is

a recap of last post of other question (which is about to be closed)


what is the hijran date for today?

To only way is to convert it, the only way I can think of is with a function

in Forms, before you populate the field (or have another readonly field) which converts it
with regards to report, you probably need to do something similar

what did you use the validate the date conversion?

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 1

Author Comment

by:deemas
ID: 10712237
today is 09/02/1425.

I canot understand your final question. Please
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10712348
how are you displaying the hijri date?

in a form, you have a date, before you set that value in the textbox, you can convert it
or have a read only textbox (or caption) field which holds the equivalent hijri date - this way you see both gregorian and hijri



this code here


    Dim sDate
    Call VariantChangeTypeEx(sDate, Now(), 1025, &H8, vbString)
    MsgBox "From " & Now() & " I got " & sDate


I got from 30/03/2004 to 09/02/1425

if you put this code in a function

e.g.

public function ConvertToHijri(byval sDate as date) as string

    Dim sDate
    Call VariantChangeTypeEx(sDate, sDate, 1025, &H8, vbString)
    ConvertToHijri = sDate

end function

then in the form, call

txtDate.value = ConvertToHijri(field.GregorianDate)
0
 
LVL 1

Author Comment

by:deemas
ID: 10712399
Please give me some time
I am in middle of preparing important Management Report.


I will check, and come back to you.

0
 
LVL 1

Author Comment

by:deemas
ID: 10712602
i am getting a compile error "Duplication declaration in current scope",

By the way sdate is the date gregorian date you are refering?
0
 
LVL 1

Author Comment

by:deemas
ID: 10712606
i am getting a compile error "Duplication declaration in current scope",

By the way sdate is the date gregorian date you are refering?

Public Function ConvertToHijri(ByVal sDate As Date) As String
    Dim sDate
    Call VariantChangeTypeEx(sDate, sDate, 1025, &H8, vbString)
    ConvertToHijri = sDate
End Function
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 125 total points
ID: 10712686
Im sorry my mistake, I made a duplicate declaration try this instead



Public Function ConvertToHijri(ByVal sFromDate As Date) As String
    Dim sDate
    Call VariantChangeTypeEx(sDate, sFromDate, 1025, &H8, vbString)
    ConvertToHijri = sDate
End Function


make sure you have defined VairantChangeTypeEx at the top of the module

Declare Function VariantChangeTypeEx _
 Lib "oleaut32.dll" _
 (ByRef pvargDest As Variant, _
 ByRef pvarSrc As Variant, _
 ByVal lcid As Long, _
 ByVal wFlags As Integer, _
 ByVal vt As VbVarType) As Long
0
 
LVL 1

Author Comment

by:deemas
ID: 10712866
Thanks a lot ,

you deserve for full Points,

Can you please explian me syntex of this fuction, and also is it possible to change the Hijri to Gregorian.

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10712890
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_8h14.asp

Unfortunately I do not know all the parameters for the different flags

I think the gregorian is &H40

so if you pass in a hijri date, and put &H40 instead of &H8, see what you get

(maybe create another function, same type of thing except called ConvertToGregorian)



0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question