none
problem working with datetime datatype in VB.net RRS feed

  • Question

  • Hi, 

    My project requries me to generate reports from data available in the MS Access Data Base.
    We are getting data into dataset and then using the RDLC Table and Chart Reports to generate Reports.
     
    My Problem is - In one of the reports i need to plot an Engine Name against its expected delivery Date

    In the DataBase there is a corresponding column - Engine Expected Date.
    We want only the Date and Not time.
    SO in DataBase we have made it as ShortDate....to support only Date and not time.

    But DataColumns in DataSets does not allow 'Short Date' DataType...the only Date DataType it supports is System.DateTime....so if in DB i give Date as 15/03/2008....in dataset its getting converted to '5/3/2008 12:00:00 AM'

    On the report, the y-axis parameters are also showing Time....we don't want that.
    We want the labels on y-axis to show only date and not time.

    We tried formatting the y-axis labels in rdlc files...but seems like current version of rdlc reports does not support that.

    I am struck.
    Please suggest me ways of achieving this.

    Thanks,
    BOM Developer.
    Monday, July 7, 2008 7:00 AM

All replies

  • Siri Srinu said:

    Hi, 

    My project requries me to generate reports from data available in the MS Access Data Base.
    We are getting data into dataset and then using the RDLC Table and Chart Reports to generate Reports.
     
    My Problem is - In one of the reports i need to plot an Engine Name against its expected delivery Date

    In the DataBase there is a corresponding column - Engine Expected Date.
    We want only the Date and Not time.
    SO in DataBase we have made it as ShortDate....to support only Date and not time.

    But DataColumns in DataSets does not allow 'Short Date' DataType...the only Date DataType it supports is System.DateTime....so if in DB i give Date as 15/03/2008....in dataset its getting converted to '5/3/2008 12:00:00 AM'

    On the report, the y-axis parameters are also showing Time....we don't want that.
    We want the labels on y-axis to show only date and not time.

    We tried formatting the y-axis labels in rdlc files...but seems like current version of rdlc reports does not support that.

    I am struck.
    Please suggest me ways of achieving this.

    Thanks,
    BOM Developer.

    Hi,

    Try ToShortDateString on a DATE or DateTime then.>>




    Regards,

    John
    ________________________________________




    Option Strict On

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim aDate As DateTime = Now

    Dim shortDateString As String = aDate.ToShortDateString

    MessageBox.Show(shortDateString)

    End Sub

    End Class



    I have previously been, until recently, an MSP ( Microsoft Student Partner ).
    Monday, July 7, 2008 8:48 AM
  • Siri Srinu said:

    Hi, 

    My project requries me to generate reports from data available in the MS Access Data Base.


    Hi,

    I have just noticed, oops, are you using the Visual Basic built into ACCESS?


    If so read this post please.>>




    Regards,

    John


    I have previously been, until recently, an MSP ( Microsoft Student Partner ).
    Tuesday, July 8, 2008 1:31 AM


  • 1 
    2    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
    3        Dim aDate As DateTime = Now 
    4        MessageBox.Show(aDate.Date
    5    End Sub 

    Hi 

    Try this and let me know


    O/P
    7/8/2008

    is this what u needed?

    Regards,
    Manoj
    Tuesday, July 8, 2008 9:13 AM
  • Hi Manoj,

    In rdlc table report, i tried setting the value of a text box as -
    "=(CDate(Fields!EngineDate.Value)).Date"......this displays value as Date Time again...not just Date.

    In form if i try to give the text of a label as EngineDate.Date....it works perfectly fine and displays only date part of it.

    Donno whats going wrong in reports.

    Thanks
    Wednesday, July 9, 2008 5:42 AM
  • Hi Siri,

    Because your issue mainly relates the use of the ReportViewer control, it is the best option to post this kind of issue to Visual Studio Report Controls for the better answers.

    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, July 9, 2008 11:50 AM
    Moderator
  • You have to properly set format properties in RDLC table cell.

    Right click on cell, select "property" then "format" (hope this are english menu voices because I use italian visual studio).

    C.
    Friday, July 11, 2008 9:30 AM
  • yeah, Claudi, that's how it is easily done.   I think the format setting the original poster wants ends up being  "d"


    to do it via expression 

    =FormatDateTime(Fields!EngineDate.Value,2)
    Living my life at 123mph in 11.15 seconds
    Friday, July 11, 2008 1:19 PM
  • Thank you Blasty for the solution. FormatDateTime works in rdlc report too. 
    Wednesday, October 26, 2011 3:33 PM