Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Time validation (IsTime)

Posted on 2005-05-04
2
Medium Priority
?
380 Views
Last Modified: 2008-02-01
Hi, All!
The problem is I'm trying to move my data from Excel spreadsheet to  MS SQL DB.
It's very important to keep data clean, so I need validate some columns, one of them time
Let say time is 10:59a
IsDate("10:59a") = true
But it's wrong, SQL Server won't accept it.
Any ideas how to validate time like that.
0
Comment
Question by:bogdem
2 Comments
 
LVL 18

Accepted Solution

by:
JR2003 earned 300 total points
ID: 13928881
You could wirte an 'IsSQLServerDate' function and use tha instead.
Here's one it will need some work but you can get the idea of how to write one.

Public Function IsSQLServerDate(ByVal vIn)

    IsSQLServerDate = False
    If IsDate(vIn) Then
        IsSQLServerDate = True
        If Right(vIn, 1) = "a" Then
            IsSQLServerDate = False
        End If
    End If

End Function


0
 
LVL 6

Expert Comment

by:PePi
ID: 13930612
maybe because the native datatype for SQL is datetime or smalldatetime. which means that you need to pass the Date portion instead of just the time. so instead of placing "10:59a", it should be something like "05/04/2005 10:59am".
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

564 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