Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert

Status
Not open for further replies.

Chris16

Programmer
Oct 28, 2009
8
GB
Hi, can someone help me. I'm converting julian to gregorian dates. Using the basic syntax (VB) having trouble. My code reads as follows:
Function ConJul(JulianDate As Long)
ConJul = DateSerial(1900 + Int(JulianDate / 1000), 1, JulianDate Mod 1000)
End Function

Not working.

Also, converting Kg to lbs, is this possible in crystal.

Thank you very much.

Chris

 
What does "not working" mean:

Wrong result?
Error message?

To convert Kg to pounds multiply the Kg by 2.2046.... Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken,

Sorry, getting a error message saying, "Statement needed". Option explicit possibly, really unsure, as you can tell I'm a newbie. I would rather try and stay in crystal syntax if I can. I apologize for being vague.

Chris
 
OK, if you want to stay in Crystal syntax, I can help you myself. Answer these three questions:

What is the field that you need to convert?
What values does it display if you put it on the report?
What should these end up as? Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken,

Hello again.

What is the field that you need to convert?

Field name is SDTRDJ

What values does it display if you put it on the report?

101,205, 101,198, 101,129, etc.

What should these end up as?

7/11/01, 8/12/01, etc. (in that date format)

Thank you Ken, any help is much appreciated.

Chris
 
The formula will be something like:

datevalue("12/31/1899") + {SDTRDJ}

What you have to discover is what the starting date is. I have seen 12/31/1899 used but yours may be different. If you can't figure it out, add the following formula to your report using the date it SHOULD be for one record. That record will give you the starting date:

datevalue("7/25/2001") - {SDTRDJ} Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Still not working. I'll figure it out. I'm defintely doing something wrong. Thank you for your help.

datevalue("7/25/2001") - {SDTRDJ} is all I need?

Thanks again.

Have a good day.

Chris

 
You need the first formula, but you need to know the starting date for your system. This you can identify by using the second formula. Your field is simply the number of days since this starting date.

Use the second formula to identify the starting date by following these steps:

1) Locate one record in your report whose date you know.
2) Put the date that this record should print into the second formula and put this formula onto the detail band.
3) Note the date it gives you for that record.
4) Put this date the first formula and put it on the detail band. It should calculate all dates correctly. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
The Julian dates you list as examples are for this year. That means the start date is January 1, 2001. For example the julian date for today, August 1, 2001 is 213.
In VB you would just add the julian date to Jan 1.

I am new to crystal so I may be missing something here, but I do a lot of this in VB.

Hope this helps.
 
Theologian,

Thanks for catching my mistake. I didn't notice that his examples started with the year.

Chris16, Try this formula:

WhileReadingRecords;
NumberVar Yr;
NumberVar Dy;
Dy := Remainder ({SDTRDJ},1000) ;
Yr := ({SDTRDJ} - Dy ) / 1000;
Date (1900 + yr,1,1) + dy -1

Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Ken, Theo:

THANK YOU VERY MUCH!!!!
GOT IT WORKING, PSYCHED.

I APPRECIATE ALL YOUR HELP.

THANKS AGAIN,

CHRIS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top