Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

datagrid formatting problem!

Posted on 2002-03-13
6
Medium Priority
?
215 Views
Last Modified: 2010-05-02
i got a datagrid which i want to show the date
as "dd-mm-yyyy hh:mm:ss". the data in the sql server table
is defined as datatime. however, when i select the data
into a datagrid my data->
"01-12-2001 00:00:00" becomes "01-12-2001" in the datagrid. It just never shows the "00:00:00"
but if the data is "01-12-2001 23:59" it shows the data
in its orginal form eg '01-12-2001 23:59". how to solve this problem i have?
0
Comment
Question by:spiral
[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
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6863251
Not very sure if this can work for SQL Server:

Select Format(myDate,'dd-mm-yyyy hh:mm:ss') As myDate From myTable
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 6863451
Well, I just did this:
1. Right click on the grid, select Properties.
2. Click the Format Tab
3. Select the date/time column from Format Item Combo.
4. Select Format Type = Custom
5. Format string text box appears, create a mask.  Mine looks like:
dd-mm-yyyy hh:mm:ss

The column data looks like:
01-02-2002 00:00:00
01-02-2002 01:01:01
02-02-2002 12:59:00
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6863592
Please maintain your open questions:
Questions Asked 17
Last 10 Grades Given B A A B A B B B B  
Question Grading Record 9 Answers Graded / 9 Answers Received

Thanks,
Anthony
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:sunyuchen
ID: 6863678
maybe u can try this in sql statement
select convert(varchar, myDate, 109) from tblTime
0
 

Author Comment

by:spiral
ID: 6863711


the answer which being propose doesnt work
0
 
LVL 1

Accepted Solution

by:
cnealy earned 280 total points
ID: 6865377
I'm doing something similar in one of my data grids.   I was able to format a date column by using the StdDataFormat.  Try changing the line where I have objFormat.Format = "mm/dd/yyy" to the format that you want.

Dim objFormat As StdDataFormat 'for using DataFormat

For Each c In dbgCourtHearings.Columns
  Select Case c.DataField
  Case "Court_Date_ID"
    c.Visible = False
  Case "Court_Hearing_Date"
    c.Width = 1100
    Set objFormat = New StdDataFormat
    objFormat.Format = "mm/dd/yyyy"
    Set c.DataFormat = objFormat
  Case "Court_Hearing_Time"
    c.Width = 1000
    'set time format
    Set objFormat = New StdDataFormat
    objFormat.Format = "Medium Time"
    Set c.DataFormat = objFormat
  Case "Hearing_Type_Description"
    c.Width = 2700
  End Select
Next c
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 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