Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Return Value of Date ans Null Function.

Posted on 2009-04-07
11
Medium Priority
?
206 Views
Last Modified: 2012-05-06
Hi,

I want to write a function for my code below.

to something like :

 Public Shared Function Assign_Correct_Date_Value(ByVal strData As String) As ....?

        If IsDate(strData) Then
                                        return "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
                                    Else
                                        return DBNull.Value
                                    End If

    End Function

Is it possible?

Thank you.


If IsDate(strData) Then
                                        strSQLCommand &= "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
                                    Else
                                        strSQLCommand &= DBNull.Value
                                    End If

Open in new window

0
Comment
Question by:emi_sastra
[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
  • 5
11 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24090739
And that is for ?
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24090782
Pardon me?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24090925
You will use that for a stored procedure or for what ?
0
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.

 
LVL 1

Author Comment

by:emi_sastra
ID: 24090948
You will use that for a stored procedure or for what ?
No.

Please see below code.

Thank you.
If ERV_Global.Is_Date_Column_Field(dtRow("ColumType")) Then
                                    If IsDate(strData) Then
                                        strSQLCommand &= "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
                                    Else
                                        strSQLCommand &= DBNull.Value
                                    End If
                                End If

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24091075
That way I don't know if its possible ... if you use the same to build the insert values you can not include the date field but that way I don't think
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24091179
Ok.

  If IsDate(strData) Then
                                        strSQLCommand &= "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
                                    Else
                                        strSQLCommand &= DBNull.Value
                                    End If



Does  strSQLCommand &= DBNull.Value is a valid command for insert or update?

i.e. strSQLCommand  =  "INSERT INTO TABLEA (Date) VALUES(" & DBNull.Value

Thank you.
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24091214
Wait a moment ... I don't to that way a long time ago but you can try this way

If IsDate(strData) Then
     strSQLCommand &= "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
Else
     strSQLCommand &= " NULL "
End If

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24091307
So, below function solve the problem?

Public Shared Function Assign_Correct_Date_Value(ByVal strData As String) As String

        If IsDate(strData) Then
            Return "'" & Format(CDate(strData), "yyyy/MM/dd") & "'"
        Else
            Return " NULL "
        End If

    End Function

Thank you.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24091457
Not 100% sure but can you try ? I think is solves.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24091539
Ok.

Thank you very much for your help.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24091572
It works.
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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

670 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