Solved

problem on displaying date

Posted on 2006-06-14
18
360 Views
Last Modified: 2008-01-09
why on crystal report the date is displayed ubnormal i.e
when i want to display #1/6/2006# meaning of first of JUNE, the result displayed as 6/1/2006 as JANUARY and sure the result will be different
i tried to play arround the formating but it doesn't work. i use crystal report 9 with visual basic 6.0
 
0
Comment
Question by:howidaelrasheed
[X]
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
  • 7
  • 5
  • 3
  • +2
18 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 16901147
Hi howidaelrasheed,

Crystal Reports should show the date in the correct format if you just add the field to the report.
If you format the field by Right_click and FormatField, then ALL the date formats that are listed show 1st March 1999 (in various formats).  There is no dd-mm-yyyy option listed.
To format in a specific way, choose the one that says 03/01/1999 for example and choose customize. You can then modify any aspect of the date format that you want.

Pete
0
 

Author Comment

by:howidaelrasheed
ID: 16901269
it doesn't work correctly
0
 
LVL 77

Expert Comment

by:peter57r
ID: 16901309
Maybe I'm misreading your Q.

Are you just adding a date field to your report from your database, or are you creating formula field with the specific date value in it?
(If you are entering the date explicitly in a formula then it will assume you mean mm/dd/yyyy.)

Pete
0
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
LVL 42

Expert Comment

by:frodoman
ID: 16902159
Check the regional settings on your PC.  Depending on these settings Crystal (and most other applications) will interpret 1/6 as either June 1st or January 6th.

0
 
LVL 1

Expert Comment

by:wsinv
ID: 16904031
You can set the date properties within Crystal reports.

Open Crystal Reports

Select File>Options

Select the Fields Tab > Click on the Date Button

Select the Date Tab

Select the date format you wish to change. (i.e. system default short format)

once selected, click on customize.

There is a section called Order:  Choose YMD , DMY or MDY as your default...

Good Luck,

wsinv

 
0
 

Author Comment

by:howidaelrasheed
ID: 16909574
thanx for reply
I don't know where is the problem resides. here what i follow
I create two textbox to indicate Fromdate and ToDate in visual basic 6.0
I wrote in Fromdate textbox 1/6/2006
ToDate textbox 30/6/2006
and press the button which contains theo following code:
------------------------
If Not IsDate(txtFromDate) Or Not IsDate(txtToDate) Then
        MsgBox " incorrect Date"
        Exit Sub
    End If
     myselect1 = Trim("#" & txtFromDate.Text & "#")
       myselect2 = Trim("#" & txtToDate.Text & "#")
       myreport = "\rpt_actualDelivery" + ".rpt"
     
        rpt_actualDelivery.Show

--------------------------------
on the  rpt_actualDelivery form which contains the crystalreport viewer i wrote the following:
------------------
Private appp As CRAXDRT.Application
Private rpt As CRAXDRT.Report
Private Sub Form_Load()
    On Error Resume Next
 
    Set appp = New CRAXDRT.Application
    Set rpt = New CRAXDRT.Report
    Set rpt = appp.OpenReport("" & App.Path & "\ReportS" & myreport, 0)
    rpt.BottomMargin = 0
    rpt.LeftMargin = 0
    rpt.RightMargin = 0
    rpt.TopMargin = 0
           
            If Not myselect1 = "" Then
                rpt.FormulaFields(1).Text = myselect1
            End If
            If Not myselect2 = "" Then
                rpt.FormulaFields(2).Text = myselect2
            End If
    CRViewer91.ReportSource = rpt
    CRViewer91.ViewReport
   
    myselect1 = ""
    myselect2 = ""
End Sub

------------------
 when i run the application the report date appears as January Not JUNE when i change the date on FromDate textbox to 14/6/2006 the report appears as JUNE.
so what is the wrong on my code??
Regards.
0
 
LVL 1

Expert Comment

by:wsinv
ID: 16910925
I do not believe there is anything wrong with your code. I think your setings in crystal reports needs to be changed.

Have you tried the suggestion from my last post?

wsinv
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16925318
I agree.  Either you r setting in Crystal is incorrect or your regional setting is incorrect.

I find dates diffivult to deal with especially when entering them as a string.  Have you tried using a DatePicker or Calendar control to enter the dates?

mlmcc
0
 

Author Comment

by:howidaelrasheed
ID: 16928773
i tired all your solutions but no response the problem is still there
is it a problem on crystal report (i use version 9)
here what i configure the crystal report:
on Edit Formula for @FromDate i wrote #1/6/2006#
on Format Field is Date DMY
on Edit Fromula for @ToDate :#30/08/2006#
same thing on Format Field
when I run it it display the @Fromdate formula as 6/1/2006 as Jaunary
i really do not know what is the problem i do everything that i could do change the setting on control panel and play around the date configuration on crystal report but nothing works. the problem also when i try to write @FromDate for example as #14/6/2006# it displayed as June why this changes happens is it a problem on crsytal report itself or WHAT???
pls help because i have many reports depends on this idea.. what can i do if this not works?? it is critical to me.
Reards....
0
 

Author Comment

by:howidaelrasheed
ID: 16929237
any Help plssss
0
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 16929481
Like I said many posts back, if you enter a date between #..# it will be assumed that it is in mm/dd/yy format.  Only if that does not produce a valid date will other formats be tried.

Therefore you must enter it in mm/dd/yy format or use yyyy-mm-dd which will not be misinterpreted.

Pete
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16929500
>>#14/6/2006# it displayed as June why
It is displayed as June because there is no 14th month.

mlmcc
0
 

Author Comment

by:howidaelrasheed
ID: 16929629
thanx Pete
so what is the suitable way to write it instead of using #..#
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 125 total points
ID: 16929816
Try something like this

rpt.FormulaFields(1).Text = Date(right(myselect1,4),mid(myselect1,3,2),left(myselect1,2))

mlmcc
0
 

Author Comment

by:howidaelrasheed
ID: 16978134
i have one more question: if i want to display monthname it will display it as configured from control panel. is there anyway to customize it from either crystalreport or from visual basic to aspecific monthname like i want to customize it to dsiplay it in arabic format for exmple.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16981077
Sure.  Create a formula like

numbervar intMonth;
intMonth := mid(myselect1,3,2);
if intMonth = 1 then
  "January"
else if intMonth = 2 then
  "February"
...
else if intMonth = 12 then
  "December"

Obviously change the month names to what you want.

mlmcc

0
 

Author Comment

by:howidaelrasheed
ID: 16991329
thank you very much dear mlmcc you deserve more than THANK You
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16998343
Glad i could help

Thanks for the kind words.

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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